package com.njtoyo.taxi.admin.rest.controller.local_service.commodity;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njtoyo.taxi.admin.aop.PermissionScope;
import com.njtoyo.taxi.admin.rest.presenter.local_service.commodity.CommodityExamineDetailsPresenter;
import com.njtoyo.taxi.admin.rest.presenter.local_service.commodity.CommodityExaminePagePresenter;
import com.njtoyo.taxi.admin.rest.wrapper.local_service.commodity.CommodityExaminePageWrapper;
import com.njtoyo.taxi.admin.rest.wrapper.local_service.commodity.CommodityExamineWrapper;
import com.njtoyo.taxi.admin.service.local_service.commodity.CommodityExamineService;
import com.taxi.entity.common.RestResult;
import com.njtoyo.taxi.entity.backend.AdminUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.Valid;

@RestController
@Api(value = "商品审核管理", tags = "商品审核管理")
@RequestMapping("/local-service/commodity-examine")
public class CommodityExamineController {

    @Autowired
    private CommodityExamineService examineService;

    @GetMapping("")
    @ApiOperation(value = "商品审核列表", notes = "商品审核列表,权限：")
        //    @PermissionScope(names = {""})
    RestResult<Page<CommodityExaminePagePresenter>> getPage(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser,
                                                            @Valid CommodityExaminePageWrapper wrapper) {
        return examineService.getPage(adminUser, wrapper);
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "商品审核详情", notes = "商品审核详情,权限：")
        //    @PermissionScope(names = {""})
    RestResult<CommodityExamineDetailsPresenter> details(@PathVariable("id") Long id) {
        return examineService.details(id);
    }

    @PatchMapping("/{id}")
    @ApiOperation(value = "商品审核", notes = "商品详情,权限：life_commodity_update")
    @PermissionScope(names = {"life_commodity_update"})
    RestResult examine(@PathVariable("id") Long id,
                       @Valid @RequestBody CommodityExamineWrapper wrapper) {
        return examineService.examine(id, wrapper);
    }

}
